<!DOCTYPE html>
<html>
	{include file="public1/_header" /}
	<style type="text/css">
		.panel {
			margin: 10px 10px 10px 0;
		}
	</style>
	<body>
		<div class="x-nav">
			<span class="layui-breadcrumb">
				<a href="">首页</a>
				<a>
					<cite>教室/科目列表</cite></a>
			</span>
			<a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()"
			 title="刷新">
				<i class="layui-icon layui-icon-refresh" style="line-height:30px"></i></a>
		</div>
		<div class="layui-fluid">
			<div class="layui-row layui-col-space15">
				<div class="layui-col-md12">
					<div class="layui-card">
						<div class="layui-card-body ">
							<div class="layui-row">
								<div>教室列表</div>
								<table class="layui-hide" id="test" lay-filter="test"></table>
								<hr>
								<div><span class="room_name" style="color: red;"></span><br>科目列表</div>
								<table class="layui-hide" id="subject" lay-filter="subject"></table>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<script type="text/html" id="barDemo">
			<a class="layui-btn layui-btn-xs">查看</a>
		</script>
		<script>
			layui.use(['util','table'], function() {
				var table = layui.table;
				var util = layui.util;
				var tableInfo = table.render({
					elem: '#test',
					url: "{:url('bancard/Exam/roomdata')}",
					title: '用户数据表',
					where:{
						id:{$Think.get.id}
					},
					cols: [
						[
							{
								field: 'room_name',
								title: "教室"
							}, {
								field: 'number_start',
								title: "开始准考证号"
							},
							{
								field: 'number_end',
								title: "结束准考证号"
							},

							{
								fixed: 'right',
								title: "{:lang('action')}",
								toolbar: '#barDemo',
								width: 180
							}
						]
					],
					done:function(res){
						var id = res.data[0].id;
						var room_name = res.data[0].room_name;
						$(".room_name").html(room_name);
						table.render({
							elem: '#subject',
							url: "{:url('bancard/Exam/subject')}",
							title: '用户数据表',
							where:{
								id:id
							},
							cols: [
								[ {
										field: 'subject_name',
										title: "科目名称"
									},
									{
										field: 'start_time',
										title: "开始时间",
										templet: function(d) {
											if (d.start_time) {
												var logoSrc = util.toDateString(d.start_time * 1000, "yyyy-MM-dd HH:mm:ss");
											} else {
												var logoSrc = "--";
											}
										
											return logoSrc;
										},
									},
									{
										field: 'end_time',
										title: "结束时间",
										templet: function(d) {
											if (d.end_time) {
												var logoSrc = util.toDateString(d.end_time * 1000, "yyyy-MM-dd HH:mm:ss");
											} else {
												var logoSrc = "--";
											}
										
											return logoSrc;
										},
									},
									{
										field: 'teacher_name',
										title: "监考老师"
									}
								]
							],
							page: false
						});
					},
					page: true
				});

				//监听行工具事件
				table.on('row(test)', function(obj) {
					var data = obj.data;
					$(".room_name").html(data.room_name);
					var info = table.render({
						elem: '#subject',
						url: "{:url('bancard/Exam/subject')}",
						title: '用户数据表',
						where:{
							id:data.id
						},
						cols: [
							[ {
									field: 'subject_name',
									title: "科目名称"
								},
								{
									field: 'start_time',
									title: "开始时间",
									templet: function(d) {
										if (d.start_time) {
											var logoSrc = util.toDateString(d.start_time * 1000, "yyyy-MM-dd HH:mm:ss");
										} else {
											var logoSrc = "--";
										}
									
										return logoSrc;
									},
								},
								{
									field: 'end_time',
									title: "结束时间",
									templet: function(d) {
										if (d.end_time) {
											var logoSrc = util.toDateString(d.end_time * 1000, "yyyy-MM-dd HH:mm:ss");
										} else {
											var logoSrc = "--";
										}
									
										return logoSrc;
									},
								},
								{
									field: 'teacher_name',
									title: "监考老师"
								}
							]
						],
						page: false
					});
				});


				

			});
		</script>
	</body>
</html>
